﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: 02 November 2012 16:44:34
// Code is generated using templates: SD.TemplateBindings.Linq
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using SD.LLBLGen.Pro.LinqSupportClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

using NetDon.OA.Data;
using NetDon.OA.Data.DaoClasses;
using NetDon.OA.Data.EntityClasses;
using NetDon.OA.Data.FactoryClasses;
using NetDon.OA.Data.HelperClasses;
using NetDon.OA.Data.RelationClasses;

namespace NetDon.OA.Data.Linq
{
	/// <summary>Meta-data class for the construction of Linq queries which are to be executed using LLBLGen Pro code.</summary>
	public partial class LinqMetaData : ILinqMetaData
	{
		#region Class Member Declarations
		private ITransaction _transactionToUse;
		private FunctionMappingStore _customFunctionMappings;
		private Context _contextToUse;
		#endregion
		
		/// <summary>CTor. Using this ctor will leave the transaction object to use empty. This is ok if you're not executing queries created with this
		/// meta data inside a transaction. If you're executing the queries created with this meta-data inside a transaction, either set the Transaction property
		/// on the IQueryable.Provider instance of the created LLBLGenProQuery object prior to execution or use the ctor which accepts a transaction object.</summary>
		public LinqMetaData() : this(null, null)
		{
		}
		
		/// <summary>CTor. If you're executing the queries created with this meta-data inside a transaction, pass a live ITransaction object to this ctor.</summary>
		/// <param name="transactionToUse">the transaction to use in queries created with this meta-data</param>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(ITransaction transactionToUse) : this(transactionToUse, null)
		{
		}
		
		/// <summary>CTor. If you're executing the queries created with this meta-data inside a transaction, pass a live ITransaction object to this ctor.</summary>
		/// <param name="transactionToUse">the transaction to use in queries created with this meta-data</param>
		/// <param name="customFunctionMappings">The custom function mappings to use. These take higher precedence than the ones in the DQE to use.</param>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(ITransaction transactionToUse, FunctionMappingStore customFunctionMappings)
		{
			_transactionToUse = transactionToUse;
			_customFunctionMappings = customFunctionMappings;
		}
		
		/// <summary>returns the datasource to use in a Linq query for the entity type specified</summary>
		/// <param name="typeOfEntity">the type of the entity to get the datasource for</param>
		/// <returns>the requested datasource</returns>
		public IDataSource GetQueryableForEntity(int typeOfEntity)
		{
			IDataSource toReturn = null;
			switch((NetDon.OA.Data.EntityType)typeOfEntity)
			{
				case NetDon.OA.Data.EntityType.AreaEntity:
					toReturn = this.Area;
					break;
				case NetDon.OA.Data.EntityType.AttachmentsEntity:
					toReturn = this.Attachments;
					break;
				case NetDon.OA.Data.EntityType.CityEntity:
					toReturn = this.City;
					break;
				case NetDon.OA.Data.EntityType.CompanyEntity:
					toReturn = this.Company;
					break;
				case NetDon.OA.Data.EntityType.ConfigurationEntity:
					toReturn = this.Configuration;
					break;
				case NetDon.OA.Data.EntityType.CustomerGoodsShippingTypeEntity:
					toReturn = this.CustomerGoodsShippingType;
					break;
				case NetDon.OA.Data.EntityType.CustomerInfoEntity:
					toReturn = this.CustomerInfo;
					break;
				case NetDon.OA.Data.EntityType.DeliveryOrderCodeConfigEntity:
					toReturn = this.DeliveryOrderCodeConfig;
					break;
				case NetDon.OA.Data.EntityType.DepartmentEntity:
					toReturn = this.Department;
					break;
				case NetDon.OA.Data.EntityType.DepartmentManagerEntity:
					toReturn = this.DepartmentManager;
					break;
				case NetDon.OA.Data.EntityType.DictionaryEntity:
					toReturn = this.Dictionary;
					break;
				case NetDon.OA.Data.EntityType.DictionaryCategoryEntity:
					toReturn = this.DictionaryCategory;
					break;
				case NetDon.OA.Data.EntityType.FunctionEntity:
					toReturn = this.Function;
					break;
				case NetDon.OA.Data.EntityType.GoodsTravelDaysConfigEntity:
					toReturn = this.GoodsTravelDaysConfig;
					break;
				case NetDon.OA.Data.EntityType.ImageEntity:
					toReturn = this.Image;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderEntity:
					toReturn = this.IssuingOrder;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderDeliveryEntity:
					toReturn = this.IssuingOrderDelivery;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderOnWayTrackEntity:
					toReturn = this.IssuingOrderOnWayTrack;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderOnWayTrackCommentEntity:
					toReturn = this.IssuingOrderOnWayTrackComment;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderOnWayTrackHistoryEntity:
					toReturn = this.IssuingOrderOnWayTrackHistory;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderReceiptInfoTrackEntity:
					toReturn = this.IssuingOrderReceiptInfoTrack;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderReceiptInfoTrackCommentEntity:
					toReturn = this.IssuingOrderReceiptInfoTrackComment;
					break;
				case NetDon.OA.Data.EntityType.IssuingOrderVehicleInfoEntity:
					toReturn = this.IssuingOrderVehicleInfo;
					break;
				case NetDon.OA.Data.EntityType.LogEntity:
					toReturn = this.Log;
					break;
				case NetDon.OA.Data.EntityType.MachineAccountIncomeEntity:
					toReturn = this.MachineAccountIncome;
					break;
				case NetDon.OA.Data.EntityType.MachineAccountPaymentEntity:
					toReturn = this.MachineAccountPayment;
					break;
				case NetDon.OA.Data.EntityType.PostEntity:
					toReturn = this.Post;
					break;
				case NetDon.OA.Data.EntityType.ProductEntity:
					toReturn = this.Product;
					break;
				case NetDon.OA.Data.EntityType.ProvinceEntity:
					toReturn = this.Province;
					break;
				case NetDon.OA.Data.EntityType.ReportEntity:
					toReturn = this.Report;
					break;
				case NetDon.OA.Data.EntityType.ReportCategoryEntity:
					toReturn = this.ReportCategory;
					break;
				case NetDon.OA.Data.EntityType.RevenueMachineAccountEntity:
					toReturn = this.RevenueMachineAccount;
					break;
				case NetDon.OA.Data.EntityType.RevenueMachineAccountInvoiceEntity:
					toReturn = this.RevenueMachineAccountInvoice;
					break;
				case NetDon.OA.Data.EntityType.RevenueMachineAccountInvoiceOrderEntity:
					toReturn = this.RevenueMachineAccountInvoiceOrder;
					break;
				case NetDon.OA.Data.EntityType.RevenueMachineAccountInvoiceReceiptEntity:
					toReturn = this.RevenueMachineAccountInvoiceReceipt;
					break;
				case NetDon.OA.Data.EntityType.RoleEntity:
					toReturn = this.Role;
					break;
				case NetDon.OA.Data.EntityType.RoleFunctionEntity:
					toReturn = this.RoleFunction;
					break;
				case NetDon.OA.Data.EntityType.RouteEntity:
					toReturn = this.Route;
					break;
				case NetDon.OA.Data.EntityType.ShuntingCostConfigEntity:
					toReturn = this.ShuntingCostConfig;
					break;
				case NetDon.OA.Data.EntityType.SysParameterEntity:
					toReturn = this.SysParameter;
					break;
				case NetDon.OA.Data.EntityType.UserEntity:
					toReturn = this.User;
					break;
				case NetDon.OA.Data.EntityType.UserRoleEntity:
					toReturn = this.UserRole;
					break;
				case NetDon.OA.Data.EntityType.VehicleModelEntity:
					toReturn = this.VehicleModel;
					break;
				default:
					toReturn = null;
					break;
			}
			return toReturn;
		}

		/// <summary>returns the datasource to use in a Linq query when targeting AreaEntity instances in the database.</summary>
		public DataSource<AreaEntity> Area
		{
			get { return new DataSource<AreaEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting AttachmentsEntity instances in the database.</summary>
		public DataSource<AttachmentsEntity> Attachments
		{
			get { return new DataSource<AttachmentsEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CityEntity instances in the database.</summary>
		public DataSource<CityEntity> City
		{
			get { return new DataSource<CityEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CompanyEntity instances in the database.</summary>
		public DataSource<CompanyEntity> Company
		{
			get { return new DataSource<CompanyEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ConfigurationEntity instances in the database.</summary>
		public DataSource<ConfigurationEntity> Configuration
		{
			get { return new DataSource<ConfigurationEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CustomerGoodsShippingTypeEntity instances in the database.</summary>
		public DataSource<CustomerGoodsShippingTypeEntity> CustomerGoodsShippingType
		{
			get { return new DataSource<CustomerGoodsShippingTypeEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CustomerInfoEntity instances in the database.</summary>
		public DataSource<CustomerInfoEntity> CustomerInfo
		{
			get { return new DataSource<CustomerInfoEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DeliveryOrderCodeConfigEntity instances in the database.</summary>
		public DataSource<DeliveryOrderCodeConfigEntity> DeliveryOrderCodeConfig
		{
			get { return new DataSource<DeliveryOrderCodeConfigEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DepartmentEntity instances in the database.</summary>
		public DataSource<DepartmentEntity> Department
		{
			get { return new DataSource<DepartmentEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DepartmentManagerEntity instances in the database.</summary>
		public DataSource<DepartmentManagerEntity> DepartmentManager
		{
			get { return new DataSource<DepartmentManagerEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DictionaryEntity instances in the database.</summary>
		public DataSource<DictionaryEntity> Dictionary
		{
			get { return new DataSource<DictionaryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting DictionaryCategoryEntity instances in the database.</summary>
		public DataSource<DictionaryCategoryEntity> DictionaryCategory
		{
			get { return new DataSource<DictionaryCategoryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting FunctionEntity instances in the database.</summary>
		public DataSource<FunctionEntity> Function
		{
			get { return new DataSource<FunctionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting GoodsTravelDaysConfigEntity instances in the database.</summary>
		public DataSource<GoodsTravelDaysConfigEntity> GoodsTravelDaysConfig
		{
			get { return new DataSource<GoodsTravelDaysConfigEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ImageEntity instances in the database.</summary>
		public DataSource<ImageEntity> Image
		{
			get { return new DataSource<ImageEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderEntity instances in the database.</summary>
		public DataSource<IssuingOrderEntity> IssuingOrder
		{
			get { return new DataSource<IssuingOrderEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderDeliveryEntity instances in the database.</summary>
		public DataSource<IssuingOrderDeliveryEntity> IssuingOrderDelivery
		{
			get { return new DataSource<IssuingOrderDeliveryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderOnWayTrackEntity instances in the database.</summary>
		public DataSource<IssuingOrderOnWayTrackEntity> IssuingOrderOnWayTrack
		{
			get { return new DataSource<IssuingOrderOnWayTrackEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderOnWayTrackCommentEntity instances in the database.</summary>
		public DataSource<IssuingOrderOnWayTrackCommentEntity> IssuingOrderOnWayTrackComment
		{
			get { return new DataSource<IssuingOrderOnWayTrackCommentEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderOnWayTrackHistoryEntity instances in the database.</summary>
		public DataSource<IssuingOrderOnWayTrackHistoryEntity> IssuingOrderOnWayTrackHistory
		{
			get { return new DataSource<IssuingOrderOnWayTrackHistoryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderReceiptInfoTrackEntity instances in the database.</summary>
		public DataSource<IssuingOrderReceiptInfoTrackEntity> IssuingOrderReceiptInfoTrack
		{
			get { return new DataSource<IssuingOrderReceiptInfoTrackEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderReceiptInfoTrackCommentEntity instances in the database.</summary>
		public DataSource<IssuingOrderReceiptInfoTrackCommentEntity> IssuingOrderReceiptInfoTrackComment
		{
			get { return new DataSource<IssuingOrderReceiptInfoTrackCommentEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting IssuingOrderVehicleInfoEntity instances in the database.</summary>
		public DataSource<IssuingOrderVehicleInfoEntity> IssuingOrderVehicleInfo
		{
			get { return new DataSource<IssuingOrderVehicleInfoEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting LogEntity instances in the database.</summary>
		public DataSource<LogEntity> Log
		{
			get { return new DataSource<LogEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting MachineAccountIncomeEntity instances in the database.</summary>
		public DataSource<MachineAccountIncomeEntity> MachineAccountIncome
		{
			get { return new DataSource<MachineAccountIncomeEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting MachineAccountPaymentEntity instances in the database.</summary>
		public DataSource<MachineAccountPaymentEntity> MachineAccountPayment
		{
			get { return new DataSource<MachineAccountPaymentEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting PostEntity instances in the database.</summary>
		public DataSource<PostEntity> Post
		{
			get { return new DataSource<PostEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ProductEntity instances in the database.</summary>
		public DataSource<ProductEntity> Product
		{
			get { return new DataSource<ProductEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ProvinceEntity instances in the database.</summary>
		public DataSource<ProvinceEntity> Province
		{
			get { return new DataSource<ProvinceEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportEntity instances in the database.</summary>
		public DataSource<ReportEntity> Report
		{
			get { return new DataSource<ReportEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ReportCategoryEntity instances in the database.</summary>
		public DataSource<ReportCategoryEntity> ReportCategory
		{
			get { return new DataSource<ReportCategoryEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RevenueMachineAccountEntity instances in the database.</summary>
		public DataSource<RevenueMachineAccountEntity> RevenueMachineAccount
		{
			get { return new DataSource<RevenueMachineAccountEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RevenueMachineAccountInvoiceEntity instances in the database.</summary>
		public DataSource<RevenueMachineAccountInvoiceEntity> RevenueMachineAccountInvoice
		{
			get { return new DataSource<RevenueMachineAccountInvoiceEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RevenueMachineAccountInvoiceOrderEntity instances in the database.</summary>
		public DataSource<RevenueMachineAccountInvoiceOrderEntity> RevenueMachineAccountInvoiceOrder
		{
			get { return new DataSource<RevenueMachineAccountInvoiceOrderEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RevenueMachineAccountInvoiceReceiptEntity instances in the database.</summary>
		public DataSource<RevenueMachineAccountInvoiceReceiptEntity> RevenueMachineAccountInvoiceReceipt
		{
			get { return new DataSource<RevenueMachineAccountInvoiceReceiptEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RoleEntity instances in the database.</summary>
		public DataSource<RoleEntity> Role
		{
			get { return new DataSource<RoleEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RoleFunctionEntity instances in the database.</summary>
		public DataSource<RoleFunctionEntity> RoleFunction
		{
			get { return new DataSource<RoleFunctionEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RouteEntity instances in the database.</summary>
		public DataSource<RouteEntity> Route
		{
			get { return new DataSource<RouteEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ShuntingCostConfigEntity instances in the database.</summary>
		public DataSource<ShuntingCostConfigEntity> ShuntingCostConfig
		{
			get { return new DataSource<ShuntingCostConfigEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting SysParameterEntity instances in the database.</summary>
		public DataSource<SysParameterEntity> SysParameter
		{
			get { return new DataSource<SysParameterEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserEntity instances in the database.</summary>
		public DataSource<UserEntity> User
		{
			get { return new DataSource<UserEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserRoleEntity instances in the database.</summary>
		public DataSource<UserRoleEntity> UserRole
		{
			get { return new DataSource<UserRoleEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting VehicleModelEntity instances in the database.</summary>
		public DataSource<VehicleModelEntity> VehicleModel
		{
			get { return new DataSource<VehicleModelEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		#region Class Property Declarations
		/// <summary> Gets / sets the ITransaction to use for the queries created with this meta data object.</summary>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public ITransaction TransactionToUse
		{
			get { return _transactionToUse;}
			set { _transactionToUse = value;}
		}

		/// <summary>Gets or sets the custom function mappings to use. These take higher precedence than the ones in the DQE to use</summary>
		public FunctionMappingStore CustomFunctionMappings
		{
			get { return _customFunctionMappings; }
			set { _customFunctionMappings = value; }
		}
		
		/// <summary>Gets or sets the Context instance to use for entity fetches.</summary>
		public Context ContextToUse
		{
			get { return _contextToUse;}
			set { _contextToUse = value;}
		}
		#endregion
	}
}